package com.yst.suivi.data.assignation;

import javax.ejb.CreateException;
import javax.ejb.EntityBean;

import com.yst.suivi.data.AbstractEntityBean;
import com.yst.suivi.data.project.Project;
import com.yst.suivi.data.team.TeamRole;
import com.yst.suivi.data.user.User;

/**
 * @author stolf
 * @ejb.bean name="Assignation" type="CMP" cmp-version="2.x"
 *           schema="Assignation" local-jndi-name="AssignationBean"
 *           view-type="local" primkey-field = "id" reentrant = "True"
 * @ejb.home generate="local"
 * @ejb.persistence table-name = "Assignation"
 * @jboss.entity-command name = "key-generator"
 * @jboss.read-ahead eager-load-group = "most" strategy = "on-load"
 *                   page-size="25"
 * @ejb.interface local-extends = "javax.ejb.EJBLocalObject"
 * @ejb.finder signature="java.util.Collection findAll()" query="SELECT
 *             OBJECT(g) FROM Assignation AS g"
 * @ejb.finder signature="java.util.Collection findByProject(com.yst.suivi.data.project.Project prj)" query="SELECT
 *             OBJECT(g) FROM Assignation AS g where g.project=?1"
 * @ejb.finder signature="java.util.Collection findByProjectRole(com.yst.suivi.data.project.Project prj, com.yst.suivi.data.team.TeamRole role)" query="SELECT
 *             OBJECT(g) FROM Assignation AS g where g.project=?1 and g.teamRole=?2"
 */
public abstract class AssignationBean extends AbstractEntityBean implements EntityBean
{
	/**
	 * @return
	 * @throws CreateException
	 * @ejb.create-method view-type = "local"
	 */
	public String ejbCreate() throws CreateException
	{
		return null;
	}

	public void ejbPostCreate()
	{
		// by default nothing to do
	}

	/**
	 * Return the primary key of the object
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.jdbc-type type = "VARCHAR"
	 * @jboss.sql-type type = "VARCHAR(255)"
	 */
	public abstract String getId();

	/**
	 * Fix the primary key of the object. The method should be used only by the
	 * container
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setId(String id);

	/**
	 * La methode lie le projet
	 * 
	 * @return
	 * @ejb.relation name="assignement-projet" role-name = "AssignProjet"
	 *               target-role-name = "AssignProjetRole" target-multiple =
	 *               "yes" target-ejb="Project"
	 * @jboss.relation related-pk-field = "id" fk-constraint = "true" fk-column =
	 *                 "prjId"
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract Project getProject();

	/**
	 * La methode lie le projet ason responsable
	 * 
	 * @param plf
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setProject(Project prj);

	/**
	 * La methode lie le role
	 * 
	 * @return
	 * @ejb.relation name="assignement-role" role-name = "AssignRole"
	 *               target-role-name = "AssignRoleRole" target-multiple = "yes"
	 *               target-ejb="TeamRole"
	 * @jboss.relation related-pk-field = "id" fk-constraint = "true" fk-column =
	 *                 "TeamRoleId"
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract TeamRole getTeamRole();

	/**
	 * La methode lie le role
	 * 
	 * @param plf
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setTeamRole(TeamRole teamRole);

	/**
	 * La methode lie l'utilisateur
	 * 
	 * @return
	 * @ejb.relation name="assignement-user" role-name = "AssignUser"
	 *               target-role-name = "AssignUserRole" target-multiple = "yes"
	 *               target-ejb="User"
	 * @jboss.relation related-pk-field = "id" fk-constraint = "true" fk-column =
	 *                 "userId"
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract User getUser();

	/**
	 * La methode lie le role
	 * 
	 * @param plf
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setUser(User usr);
}
